from flask import Flask,render_template,request
from zhixuewang import login
import givescoretosqlite
from pandas import DataFrame

app =Flask(__name__)

@app.route("/show/info")
def index():
    return render_template("hello_world.html")

@app.route("/show/secondpage")
def gozhixue():
    return render_template("sss.html")

@app.route("/login",methods=["GET"])
def register():
    return render_template("login.html",name="as",pas="aascasv")

@app.route("/exam" ,methods=["GET"])
def doreg():
    print(request)
    username=request.args["username"]
    pwd=request.args["password"]
    try:
        login(username,pwd)
    except:
        return "用户名密码错误"
    scorelist=givescoretosqlite.sav_or_get_data(username, pwd)
    scorelist=DataFrame(scorelist)
    scorelist.columns=['序号','学校','考试','姓名','学科','分数','年排','班排','平均分']
    del scorelist['序号']
    return scorelist.to_html(index=False)


if __name__ == '__main__':
    app.run()
    #app.run(host='0.0.0.0', port=5000)